﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <title>Closure</title>
    <script type="text/javascript">

        var firstClosure;
        var secondClosure;

        function foo() {

            var x = 1;

            firstClosure = function () { return ++x; };
            secondClosure = function () { return --x; };

            x = 2; // 影响 AO["x"], 在2个闭包公有的[[Scope]]中

            alert(firstClosure()); // 3, 通过第一个闭包的[[Scope]]
        }

        foo();

        alert(firstClosure()); // 4
        alert(secondClosure()); // 3
    </script>
</head>
<body>
    <div>
        
    </div>
</body>
</html>
